package com.test.qpbgboot.base.quartz;

import com.test.qpbgboot.base.utils.SpringContextUtils;
import com.test.qpbgboot.schedule.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * 每半小时更新房间排班表和陪玩排班表，
 * 将过期的已预约改成已使用或已工作
 */
@Slf4j
public class RefreshScheduleTableJob extends QuartzJobBean {
    @Override
    protected void executeInternal(@NotNull JobExecutionContext context) throws JobExecutionException {
        log.debug("自动刷新排班表-定时任务");

        ScheduleService scheduleService = SpringContextUtils.getBean(ScheduleService.class);
        scheduleService.refreshTable();
    }
}
